package com.zkingsoft.action;

import static com.zkingsoft.common.constance.AppConstance.SAFEPATH;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.constance.SystemMessageCode;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.WebUtil;
import com.matrix.core.web.BaseAction;
import com.zkingsoft.bean.BizCollageDetail;
import com.zkingsoft.service.BizCollageDetailService;

/**
 * @description (拼团详情)
 * @author 何明
 * @date 2018-05-23 00:08
 */
@Controller
@RequestMapping(value = "bizCollageDetail")
public class BizCollageDetailAction extends BaseAction{

	@Autowired
	private BizCollageDetailService bizCollageDetailService;
	
	//记录编辑前的值Before_Edit_Value
	public static final String BEV="BizCollageDetail_BEV";
	
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value =  SAFEPATH+"/showList")
	public @ResponseBody AjaxResult showList(BizCollageDetail bizCollageDetail, PaginationVO pageVo) {
		return showList(bizCollageDetailService, bizCollageDetail, pageVo);
	}
   	
	/**
	 * 新增
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/addBizCollageDetail")
	public @ResponseBody AjaxResult addBizCollageDetail(BizCollageDetail bizCollageDetail) {
	 	int i=bizCollageDetailService.add(bizCollageDetail);
	 	if(i > 0){
	 		return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "(拼团详情)");
	 	}else {
			throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
		}
	}
	
	
	
	
	
	/**
	 * 修改
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/modifyBizCollageDetail")
	public @ResponseBody AjaxResult modifyBizCollageDetail(BizCollageDetail bizCollageDetail) {
	   		bizCollageDetail.setDetId(((BizCollageDetail)WebUtil.getSessionAttribute(BEV)).getDetId());
	   		AjaxResult result=modify(bizCollageDetailService, WebUtil.getSessionAttribute(BEV), bizCollageDetail, "(拼团详情)");
			WebUtil.removeSessionAttribute(BEV);
			return  result;
	}
	
	
	
	
   	/**
	 * 进入修改界面
	 */   
	@SaveRequestToken
   	@RequestMapping(value =  SAFEPATH+"/editForm")
	public String editForm(String id) {
		BizCollageDetail bizCollageDetail;
		if (id != null) {
			bizCollageDetail = bizCollageDetailService.findById(id);
			WebUtil.getRequest().setAttribute("obj", bizCollageDetail);
			WebUtil.setSessionAttribute(BEV, bizCollageDetail);
		}
		return "admin/BizCollageDetail-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = SAFEPATH+"/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(bizCollageDetailService, keys);
	}
  
}